
package com.jf.cloud.distribution.feign;

import com.jf.cloud.api.distribution.feign.DistributionFeignClient;
import com.jf.cloud.api.distribution.vo.DistributionSpuVO;
import com.jf.cloud.common.response.ServerResponseEntity;
import com.jf.cloud.distribution.service.DistributionSpuService;
import com.jf.cloud.distribution.service.DistributionUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RestController;
import io.swagger.v3.oas.annotations.Hidden;

import java.util.List;

/**
 * @author zz
 * @date 2021-08-05 15:38:50
 */
@RestController
@Hidden
public class DistributionFeignController implements DistributionFeignClient {

    @Autowired
    private DistributionSpuService distributionSpuService;
    @Autowired
    private DistributionUserService distributionUserService;

    @Override
    public ServerResponseEntity<DistributionSpuVO> getByDistributionId(Long distributionId) {
        DistributionSpuVO distributionSpuVO = distributionSpuService.getByDistributionSpuId(distributionId);
        return ServerResponseEntity.success(distributionSpuVO);
    }

    @Override
    public ServerResponseEntity<DistributionSpuVO> getBySpuId(Long spuId) {
        DistributionSpuVO distributionSpuVO = distributionSpuService.getBySpuId(spuId);
        return ServerResponseEntity.success(distributionSpuVO);
    }

    @Override
    public ServerResponseEntity<Void> handleSpuState(List<Long> spuIds, List<Long> shopIds, Integer state) {
        distributionSpuService.handleSpuState(spuIds, shopIds, state);
        return ServerResponseEntity.success();
    }
}
